<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp"%>
<%
	//查询急诊门诊收入
	String yydm =  input.getDesc("yydm","01");//医院代码
	String ksdm = input.getDesc("ksdm","-1"); //传入科室代码代表该科室主任
	String date = input.getDesc("start_date","2018-01-11");//开始时间
	String endDa = input.getDesc("end_date","2018-01-11");//结束时间

	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
	SimpleDateFormat sdf2 = new SimpleDateFormat("yyyyMMdd");
	String nowDate = sdf2.format(sdf.parse(date));
	String nowEndDa = sdf2.format(sdf.parse(endDa));
	
	String startDate = nowDate+"00:00:00";
	String endDate = nowEndDa+"23:59:59";

	String sqlWhere = " and js.sfrq > '"+ startDate + "' and js.sfrq < '" + endDate+"' " ;
	if(!yydm.equals("-1"))
			sqlWhere += " and js.ksdm in (select new map (id as id) from his_dept where yydm ='"+yydm+"') " ;
	if(!"-1".equals(ksdm)){
		sqlWhere += " and js.ksdm in( " + ksdm +")";
	}
	//门诊收入

	List<Map> feelist = QBuilder.db("basedb").queryHql("select new map( sum(js.zje) as zje  ) from  SF_BRJSK js , mzjl m where m.xh = js.ghxh and m.ghlb = 1 and  js.ybjszt=2 and js.jlzt = 0 " + sqlWhere+ " ");

	
	double money = 0;
	if(feelist != null && feelist.size() > 0 ){
		money = Double.parseDouble(feelist.get(0).get("zje") == null ? "0" :feelist.get(0).get("zje").toString());
	}
	//System.out.println("sssss"+sqlWhere);
	DecimalFormat df = new DecimalFormat("######0.0000"); 
	money = money/10000;
	Map<String,Object> ma = new HashMap<String,Object>();
	Map<String,Object> ma1 = new HashMap<String,Object>();
	ma.put("sumCount",df.format(money));
	ma1.put("data",ma);
	Message msg = new Message();

	msg.put("errcode",0);
	msg.put("chEmergency",ma1);

	out.println(msg);
%>